<?php
require_once "weixin_info.php";
require_once "config.php";
$sql = $mysql->query("select * from dyspw_mem_bank where  u_id = {$_SESSION['Member_info'][0]['id']} ");
$bank_list = $sql->fetch_all(MYSQLI_ASSOC);
 ?>
 <!doctype html>
 <html>

 <head>
     <meta charset="utf-8">
     <meta name="viewport"
         content="height=device-height,width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
     <meta content="telephone=no" name="format-detection" />
     <link rel="stylesheet" type="text/css" href="css/invite.css">
     <script src="js/layer/layer.js" type="text/javascript"></script>
     <title>商户提现</title>

 </head>

 <body>
     <div id="content" class="registered">
         <div class="info">
             <div>
                 <p class="left">余额 </p>
                 <p class="right"><input type="text"   value="<?php echo $_SESSION['Member_info'][0]['balance'] ?>"  readonly ></p>
                 <span class=""></span>
             </div>
             <div>
                 <p class="left">提现金额 <span>*</span></p>
                 <p class="right"><input type="number" name="money" placeholder="0.00" class="reg_nickname" required="required" onkeyup="this.value=/^[0-9]*\.?[0-9]{0,2}$/.test(this.value) ? this.value : this.value.substring(0,this.value.length-1)"></p>
                 <span class="nickname_hint"></span>
             </div>
             <div>
                 <p class="left">选择银行 <span>*</span></p>
                 <p class="right">
                     <select class="reg_bank" name="bank" style="border: none;direction: rtl;color: #aaa;width: 100%;text-align: right;">
                         <option value="">选择银行</option>
                         <?php foreach ($bank_list as $key => $val) { ?>
                             <option value="<?php echo $val['id']; ?>"><?php echo $val['bank_num'].'('.$val['username'].')'; ?></option>
                         <?php  } ?>
                     </select>
                 </p>
                 <span class="bank_hint" style="padding: 30px 10px 0 0;"></span>
             </div>

         </div>
         <div class="" style="padding: 15px 10px;">
             <p style="font-size: 13px;color: #aaa;line-height: 20px;">注：提现金额不可超过可提现金额，提现金额必须为100的倍数，提现金额必须大于100</p>
             <p style="font-size: 13px;color: #aaa;line-height: 20px;">以上信息需填写真实信息</p>
         </div>
         <p class="sure">确认提现</p>
         <div class="dialog">
             <p class="header">请完善信息</p>
         </div>

     </div>
     </div>
     <script src="js/jquery-2.2.4.min.js" type="text/javascript"></script>
     <script src="js/cupload.js"></script>
     <script type="text/javascript">
        $(function () {
            var nickname_Boolean = false;
            var bank_Boolean = false;

            //校验用户名
            $('.reg_nickname').blur(function () {
                if ($(".reg_nickname").val()) {
                    $('.nickname_hint').html("✔").css("color", "green");
                    nickname_Boolean = true;
                } else {
                    $('.nickname_hint').html("×").css("color", "red");
                    nickname_Boolean = false;
                }
            });
            $('.reg_bank').blur(function () {
                if ($(".reg_bank").val()) {
                    $('.bank_hint').html("✔").css("color", "green");
                    bank_Boolean = true;
                } else {
                    $('.bank_hint').html("×").css("color", "red");
                    bank_Boolean = false;
                }
            });

            function show() {
                $('.dialog').css("display", "block");
            }
            $(".sure").on('click', function () {
                if ( bank_Boolean && nickname_Boolean == true) {
                    var money = $("input[name='money']").val();
                   var bank_id = $(".reg_bank").val();
                   var sale_id = "<?php echo $sale[0]['id'] ?>";
                    $.ajax({
                        type: "post",
                        dataType: "JSON",
                        url: 'shop_cash_ajax.php',
                        data: {'bank_id':bank_id,'money':money},
                        success: function (res) {
                            if(res.status == 'y'){
                                layer.open({content: res.info,skin: 'msg',time: 100});
                                location.href="wallet.php";
                            }else if(res.status == 'n') {
                                layer.open({content: res.info,skin: 'msg',time: 2});
                            }else{
                                layer.open({content: '请联系管理员',skin: 'msg',time: 2});
                            }
                        }
                    });
                } else {
                    $(".dialog").show().delay(1000).fadeOut();
                }
            })

        })
 	</script>
 </body>

 </html>
